package cn.ld.module.system.dal.mapper.sms;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.module.system.controller.admin.sms.vo.channel.SmsChannelPageInVO;
import cn.ld.module.system.dal.entity.sms.SmsChannelEntity;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SmsChannelMapper extends BaseMapperX<SmsChannelEntity> {

    default PageResult<SmsChannelEntity> selectPage(SmsChannelPageInVO inVO) {
        return selectPage(inVO, new LambdaQueryWrapperX<SmsChannelEntity>()
                .likeIfPresent(SmsChannelEntity::getSignature, inVO.getSignature())
                .eqIfPresent(SmsChannelEntity::getStatus, inVO.getStatus())
                .betweenIfPresent(SmsChannelEntity::getCreateTime, inVO.getCreateTime())
                .orderByDesc(SmsChannelEntity::getId));
    }

    default SmsChannelEntity selectByCode(String code) {
        return selectOne(SmsChannelEntity::getCode, code);
    }

}
